#!/bin/bash

# Zookeeper 地址和端口
ZOOKEEPER_HOST="localhost"  # 替换为 Zookeeper 的主机名或 IP 地址
ZOOKEEPER_PORT="2181"        # Zookeeper 的端口，默认是 2181
ZOOKEEPER_HOME="D:\service\apache-zookeeper-3.8.4"        # Zookeeper 的端口，默认是 2181

# 要设置的节点路径和数据
NODE_PATH="/my_node/config/db/smc"         # 替换为你要设置的节点路径
NODE_VALUE="druid.driverClassName=oracle.jdbc.OracleDriver
            druid.username=settle
            druid.password=settle
            druid.url=jdbc:oracle:thin:@//10.180.45.175:1521/settledb
            #druid.driverClassName=com.mysql.cj.jdbc.Driver
            #druid.username=settle
            #druid.password=qfjs_MYSQL@2020
            #druid.url=jdbc:mysql://10.1.0.145:3306/settle?characterEncoding=utf8&useSSL=true&serverTimezone=GMT%2B8
            druid.initialSize=1
            druid.maxActive=100
            druid.minIdle=10
            druid.maxWait=60000
            druid.removeAbandoned=true
            druid.removeAbandonedTimeout=180
            druid.timeBetweenEvictionRunsMillis=60000
            druid.minEvictableIdleTimeMillis=25200000
            druid.validationQuery=SELECT 1 FROM DUAL
            druid.testWhileIdle=true
            druid.testOnBorrow=false
            druid.testOnReturn=false
            #poolPreparedStatements = true
            #maxPoolPreparedStatementPerConnectionSize = 50
            druid.connectionProperties=config.decrypt=false" # 要设置的节点值

if [ -z "$ZOOKEEPER_HOME" ]; then
    echo "错误: ZOOKEEPER_HOME 未设置，请设置 ZOOKEEPER_HOME 环境变量。"
    exit 1
fi

# 使用 zkCli.sh 设置节点值
$ZOOKEEPER_HOME/bin/zkCli.sh -server $ZOOKEEPER_HOST:$ZOOKEEPER_PORT <<EOF
create $NODE_PATH "$NODE_VALUE" -e
exit
EOF

echo "节点 $NODE_PATH 的值已设置为 '$NODE_VALUE'"